package com.javasm.crm.service.marketingActivity.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javasm.crm.domin.entity.marketingActivity.Returned;
import com.javasm.crm.domin.entity.marketingActivity.clinetClaim.ReturnedFindClaim;
import com.javasm.crm.mapper.marketingActivity.ReturnedMapper;
import com.javasm.crm.service.marketingActivity.ReturnedService;
import com.javasm.crm.utils.page.PageResult;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author llyp
 * @since 2021-07-12
 */
@Service
public class ReturnedServiceImpl extends ServiceImpl<ReturnedMapper, Returned> implements ReturnedService {

    @Autowired
    private ReturnedMapper returnedMapper;

    @Override
    public PageResult<Returned> ConditionFindPage(ReturnedFindClaim rfc) {

        Page page = new Page<>(rfc.getCurrent(),rfc.getSize());

        QueryWrapper queryWrapper = new QueryWrapper();

        if (rfc.getId()!=null){
            queryWrapper.eq("id",rfc.getId());
        }
        if (StringUtils.hasLength(rfc.getMarketingName())){
            queryWrapper.like("",rfc.getMarketingName());
        }
        if (rfc.getMarketingDate()!=null){
            queryWrapper.eq("",rfc.getMarketingDate());
        }
        if (rfc.getApprovalStatus()!=null){
            queryWrapper.eq("",rfc.getApprovalStatus());
        }
        if (rfc.getRewardWay()!=null){
            queryWrapper.eq("",rfc.getRewardWay());
        }

        Page<Returned> returnedPage = returnedMapper.selectPage(page, queryWrapper);

        List<Returned> records = returnedPage.getRecords();

        long total = returnedPage.getTotal();

        return new PageResult<Returned>(total,records);
    }
}
